package fr.masterglr.website.googlr;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;


/**
* @author Deepak Kumar
* @Web http://www.roseindia.net
* @Email roseindia_net@yahoo.com
*/

/**
 * Form bean for the Address Entry Screen.
 *
*/
public class AddressForm extends ActionForm
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8096568942037343948L;
	
	private String name=null;
	private String address=null;
	private String emailAddress=null;

	public void setName(String name){
		this.name=name;
	}

	public String getName(){
		return this.name;
	}

	public void setAddress(String address){
		this.address=address;
	}

	public String getAddress(){
		return this.address;
	}


	public void setEmailAddress(String emailAddress){
		this.emailAddress=emailAddress;
	}

	public String getEmailAddress(){
		return this.emailAddress;
	}


    /**
     * Reset all properties to their default values.
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
     */
    public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.name=null;
		this.address=null;
		this.emailAddress=null;
    }

    /**
     * Reset all properties to their default values.
     *
     * @param mapping The mapping used to select this instance
     * @param request The servlet request we are processing
	 * @return errors
     */
	public ActionErrors validate( 
			ActionMapping mapping, HttpServletRequest request ) {
			ActionErrors errors = new ActionErrors();
			
			if( getName() == null || getName().length() < 1 ) {
				errors.add("name",new ActionMessage("error.name.required"));
			}
			if( getAddress() == null || getAddress().length() < 1 ) {
				errors.add("address",new ActionMessage("error.address.required"));
			}
			if( getEmailAddress() == null || getEmailAddress().length() < 1 ) {
				errors.add("emailaddress",new ActionMessage("error.emailaddress.required"));
			}

			return errors;
	}

}